package com.dxh.blog.controller;

import com.dxh.blog.entity.Article;
import com.dxh.blog.service.ArticleService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author: Dengxh
 * @Date: 2020/12/20 16:03
 * @Description:
 */
@Controller
public class ArticleController {
    @Autowired
    private ArticleService articleService;


    @GetMapping("/article-list")
    public ModelAndView articleList(@RequestParam(defaultValue = "1")Integer pageNum){
        //每页显示的条数
        int pageArticleNum = 3;
        PageInfo<Article> articlePageInfo = articleService.listArticle(pageNum, pageArticleNum);

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("article",articlePageInfo);
        modelAndView.setViewName("/client/index");
        return modelAndView;
    }
}
